#pragma once
#include <string>
#include <format>
#include <winnls.h>

namespace Convert
{
std::string w2b(const wchar_t *wideCharString)
{
    int bufferSize = WideCharToMultiByte(CP_UTF8, 0, wideCharString, -1, nullptr, 0,
                                         nullptr, nullptr);
    std::string result(bufferSize - 1, 0);
    WideCharToMultiByte(CP_UTF8, 0, wideCharString, -1, &result[0], bufferSize,
                        nullptr, nullptr);
    return result;
}
std::wstring b2w(const char *multiByteString)
{
    int bufferSize = MultiByteToWideChar(CP_UTF8, 0, multiByteString, -1, nullptr,
                                         0);
    std::wstring result(bufferSize, 0);
    MultiByteToWideChar(CP_UTF8, 0, multiByteString, -1, &result[0], bufferSize);
    return result;
}
}
